package com.tbit.uqbike.service.business.impl;

import com.tbit.uqbike.object.pojo.UpKeepConfig;
import com.tbit.uqbike.service.business.UpKeepConfigService;
import com.tbit.uqbike.webmanager.dao.core.UpKeepConfigDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author yao
 * @since 2025/1/20 16:25
 */
@Service
public class UpKeepConfigServiceImpl implements UpKeepConfigService {

    @Resource
    private UpKeepConfigDao upKeepConfigDao;

    @Override
    public void edit(UpKeepConfig accountConfig) {
        upKeepConfigDao.update(accountConfig);
    }

    @Override
    public UpKeepConfig getByAccountId(Integer accountId) {
        return upKeepConfigDao.getById(accountId);
    }

    @Override
    public void insert(UpKeepConfig upKeepConfig) {
        upKeepConfigDao.insert(upKeepConfig);
    }

    @Override
    public void createOrUpdate(UpKeepConfig upKeepConfig) {
        if (upKeepConfigDao.getById(upKeepConfig.getAccountId()) == null) {
            this.insert(upKeepConfig);
        } else {
            this.edit(upKeepConfig);
        }
    }
}
